<?php 
/**
*file conf.class.php
*单例模式
*读取配置文件
*@static  $ins
*@param array $data
*
*/
defined('ACC') ||exit ('ACC Denied');

class Conf{
	protected static $ins = null;
	protected $data = array();

/**
*引入config.inc.php
*@param array $_CFG
*/
final protected function __construct(){
    include(ROOT.'include/config.inc.php');
    $this->data = $_CFG;
	}

/**
*阻止克隆
*/
final protected function __clone(){
    
    }

/**
*开放的静态方法
*@static getIns()
*/
public static function getIns(){
	if (self::$ins instanceof self) {
		return self::$ins;
	   }else {
		self::$ins = new self();
		return self::$ins;
	   }
    }

/**
*判断array中$key是否存在
*@param array['key']  $key
*/
public function __get($key){
	if (array_key_exists($key, $this->data)) {
		return $this->data[$key];
	   }else {
		return null;
	   }
    }

/**
*动态增加,修改 配置选项
*@param array['key'] $key 
*@param array['value'] $value
*/
public function __set($key,$value){
	  return $this->data[$key] = $value;
    }



}

$conf = Conf::getIns();
//print_r($conf);

?>